@ GNU AS assembler header file for Buffer
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:50:01 2012
@ Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 1995

@ OSLib---efficient, type-safe, transparent, extensible,
@ register-safe API coverage of RISC OS
@ 
@ Copyright (c) 1994-2012 Jonathan Coxhead and OSLib maintainers
@ 
@ Licence:
@ 
@    OSLib is free software; you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation; either version 1, or (at your option)
@ any later version - and this with the following clarification and
@ special exception:
@ 
@    Linking this library statically or dynamically with other modules
@ is making a combined work based on this library. Thus, the terms
@ and conditions of the GNU General Public License cover the whole
@ combination.
@ 
@    As a special exception, the copyright holders of this library
@ give you permission to link this library with independent modules
@ to produce an executable, regardless of the license terms of these
@ independent modules, and to copy and distribute the resulting
@ executable under terms of your choice, provided that you also meet,
@ for each linked independent module, the terms and conditions of the
@ license of that module. An independent module is a module which is
@ not derived from or based on this library. If you modify this
@ library, you may extend this exception to your version of the library,
@ but you are not obliged to do so. If you do not wish to do so, delete
@ this exception statement from your version.
@ 
@    OSLib is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@ GNU General Public License for more details.
@ 
@    You should have received a copy of the GNU General Public License
@ along with this programme; if not, write to the Free Software
@ Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA.

#ifndef Buffer_Hdr
#  define Buffer_Hdr

#  ifndef Get_Types
#    define Get_Types
#    include "oslib/Types.Hdr"
#  endif

#  ifndef Get_OS
#    define Get_OS
#    include "oslib/OS.Hdr"
#  endif

@Symbols for constants
#  define Buffer_Keyboard 0x0
#  define Buffer_RS423Input 0x1
#  define Buffer_RS423Output 0x2
#  define Buffer_Printer 0x3
#  define Buffer_SoundChannel0 0x4
#  define Buffer_SoundChannel1 0x5
#  define Buffer_SoundChannel2 0x6
#  define Buffer_SoundChannel3 0x7
#  define Buffer_Speech 0x8
#  define Buffer_Mouse 0x9
#  define Buffer_Dormant 0x1
#  define Buffer_EventOnEmpty 0x2
#  define Buffer_EventOnFull 0x4
#  define Buffer_UpCallOnThreshold 0x8
#  define Error_BufferManagerBadSWI 0x20700
#  define Error_BufferManagerTooManyBuffers 0x20700
#  define Error_BufferManagerBadBuffer 0x20700
#  define Error_BufferManagerInUse 0x20700
#  define Error_BufferManagerUnableToDetach 0x20700
#  define Error_BufferManagerHandleAlreadyUsed 0x20700
#  define Error_BufferManagerBufferTooSmall 0x20700
#  define Error_BufferManagerBadParm 0x20700
#  define Buffer_ServiceInsertByte 0x0
#  define Buffer_ServiceInsertBlock 0x1
#  define Buffer_ServiceRemoveByte 0x2
#  define Buffer_ServiceRemoveBlock 0x3
#  define Buffer_ServiceExamineByte 0x4
#  define Buffer_ServiceExamineBlock 0x5
#  define Buffer_ServiceUsedSpace 0x6
#  define Buffer_ServiceFreeSpace 0x7
#  define Buffer_ServicePurgeBuffer 0x8
#  define Buffer_ServiceNextFilledBlock 0x9
#  define CnpV_CountEntries 0x0
#  define CnpV_NumberFree 0x20000000
#  define CnpV_Purge 0x10000000

@Symbols for structure offsets and sizes
        .struct 0
        .skip   Int
Buffer_No                      : 

        .struct 0
        .skip   Bits
Buffer_Flags                   : 

@ abstract type
#  define Buffer_B 4

@ abstract type
#  define Buffer_InternalId 4

        .struct 0
        .skip   Int
Buffer_ServiceOp               : 

        .struct 0
Buffer_MouseData_x             : .skip   Short
Buffer_MouseData_y             : .skip   Short
Buffer_MouseData_buttons       : .skip   Byte
Buffer_MouseData_time          : .skip   4*Byte
Buffer_MouseData               : 


@Symbols for SWI's and SWI reason codes
.set XBuffer_Create,0x62940
.set Buffer_Create,0x42940
   @Entry
   @  R0 = flags (Buffer_Flags)
   @  R1 = size (Int)
   @  R2 = b (Buffer_B)
   @Exit
   @  R0 = b_out (Buffer_B)

.set XBuffer_Remove,0x62941
.set Buffer_Remove,0x42941
   @Entry
   @  R0 = b (Buffer_B)

.set XBuffer_Register,0x62942
.set Buffer_Register,0x42942
   @Entry
   @  R0 = flags (Buffer_Flags)
   @  R1 = buffer (pointer to data)
   @  R2 = end (pointer to data)
   @  R3 = b (Buffer_B)
   @Exit
   @  R0 = b_out (Buffer_B)

.set XBuffer_Deregister,0x62943
.set Buffer_Deregister,0x42943
   @Entry
   @  R0 = b (Buffer_B)

.set XBuffer_ModifyFlags,0x62944
.set Buffer_ModifyFlags,0x42944
   @Entry
   @  R0 = b (Buffer_B)
   @  R1 = eor_mask (Bits)
   @  R2 = and_mask (Bits)

.set XBuffer_ModifyFlags2,0x62944
.set Buffer_ModifyFlags2,0x42944
   @Entry
   @  R0 = b (Buffer_B)
   @  R1 = eor_mask (Bits)
   @  R2 = and_mask (Bits)
   @Exit
   @  R1 = old_value (Bits)
   @  R2 = new_value (Bits)

.set XBuffer_LinkDevice,0x62945
.set Buffer_LinkDevice,0x42945
   @Entry
   @  R0 = b (Buffer_B)
   @  R1 = wakeup_code (pointer to code)
   @  R2 = owner_change_code (pointer to code)
   @  R3 = handle (Int)
   @  R4 = workspace (pointer to Void)

.set XBuffer_UnlinkDevice,0x62946
.set Buffer_UnlinkDevice,0x42946
   @Entry
   @  R0 = b (Buffer_B)

.set XBuffer_GetInfo,0x62947
.set Buffer_GetInfo,0x42947
   @Entry
   @  R0 = b (Buffer_B)
   @Exit
   @  R0 = flags (Buffer_Flags)
   @  R1 = buffer (pointer to data)
   @  R2 = end (pointer to data)
   @  R3 = insertion_point (Int)
   @  R4 = removal_point (Int)
   @  R5 = spare (Int)
   @  R6 = used (Int)

.set XBuffer_Threshold,0x62948
.set Buffer_Threshold,0x42948
   @Entry
   @  R0 = b (Buffer_B)
   @  R1 = threshold (Int)
   @Exit
   @  R1 = old_threshold (Int)

.set XBuffer_InternalInfo,0x62949
.set Buffer_InternalInfo,0x42949
   @Entry
   @  R0 = b (Buffer_B)
   @Exit
   @  R0 = id (Buffer_InternalId)
   @  R1 = service_routine (pointer to code)
   @  R2 = workspace (pointer to Void)

#  define InsV 0x14
   @Entry
   @  R0 = b (Byte)
   @  R1 = buffer_no (Buffer_No)
   @  R9 = &14
   @Exit
   @  R2 corrupted

#  define InsV_Block 0x14
   @Entry
   @  R1 = &80000000 :OR: buffer_no (Buffer_No)
   @  R2 -> data (data)
   @  R3 = size (Int)
   @  R9 = &14
   @Exit
   @  R2 = end (pointer to Byte)
   @  R3 corrupted

#  define RemV 0x15
   @Entry
   @  R1 = buffer_no (Buffer_No)
   @  R9 = &15
   @Exit
   @  R0 = examined_b (Byte)
   @  R2 = removed_b (Byte)

#  define RemV_Block 0x15
   @Entry
   @  R1 = &80000000 :OR: buffer_no (Buffer_No)
   @  R2 = buffer (pointer to data)
   @  R3 = byte_count (Int)
   @  R9 = &15
   @Exit
   @  R2 -> end (Byte)
   @  R3 = spare (Int)

#  define CnpV 0x16
   @Entry
   @  R1 = buffer_no (Buffer_No)
   @  R9 = &16
   @Exit
   @  R0 corrupted
   @  R1 = lo8bits (Bits)
   @  R2 = hi24bits (Bits)

#  define Service_BufferStarting 0x6f
   @Entry
   @  R1 = &6F

#  define Event_OutputBufferEmpty 0x0
   @Entry
   @  R0 = &0
   @  R1 = buffer (Buffer_No)

#  define Event_InputBufferFull 0x1
   @Entry
   @  R0 = &1
   @  R1 = buffer (Buffer_No)
   @  R2 = b (Byte)

#  define Event_InputBufferFullBlockOp 0x1
   @Entry
   @  R0 = &1
   @  R1 = &80000000 :OR: buffer (Buffer_No)
   @  R2 = data (pointer to data)
   @  R3 = count (Int)

#  define UpCall_BufferFilling 0x8
   @Entry
   @  R0 = &8
   @  R1 = b (Buffer_B)
   @  R2 = &0

#  define UpCall_BufferEmptying 0x9
   @Entry
   @  R0 = &9
   @  R1 = b (Buffer_B)
   @  R2 = &FFFFFFFF

#endif
